package response;

import core.Constants;
import core.GameCharacter;
import core.GamePacket;

import java.io.IOException;

/**
 * @author Gary
 */
public class ResponseBoardAnswer extends GameResponse {

    private GameCharacter character;
    private short option;
    private boolean status;

    public ResponseBoardAnswer() {
        code = Constants.SMSG_BOARD_ANSWER;
    }

    public void setCharacter(GameCharacter character) {
        this.character = character;
    }

    public void setOption(short option) {
        this.option = option;
    }

    public void setStatus(boolean status) {
        this.status = status;
    }

    @Override
    public byte[] createResponse() {
        // Protocol: (int) id, (String) name, (short) option, (boolean) status
        GamePacket packet = new GamePacket(code);
        packet.addUint32(character.getID());
        packet.addString(character.getName());
        packet.addUint16(option);
        packet.addBool(status);

        return packet.getBytes();
    }
}
